//#define __DEBUG__
// by Xeno
#define THIS_FILE "x_m102.sqf"
#include "x_setup.sqf"
private ["_hangar", "_poss", "_vehicle"];

_mpos = markerPos QGVAR(sm_102);
_mpos set [2,0];
_mpos2 = markerPos QGVAR(sm_102_1);
_mpos2 set [2,0];
GVAR(x_sm_pos) = [_mpos, _mpos2];
// No TT: //  steal plane prototype, Rasman, second array position armor
GVAR(x_sm_type) = "normal"; // "convoy"

#ifdef __SMMISSIONS_MARKER__
if (true) exitWith {};
#endif

if (X_Client && {!GVAR(IS_HC_CLIENT)}) then {
#ifndef __TT__
	GVAR(cur_sm_txt) = (localize "STR_DOM_SIDESTRING_1021");
	GVAR(current_mission_resolved_text) = (localize "STR_DOM_SIDESTRING_1022");
#else
	GVAR(cur_sm_txt) = (localize "STR_DOM_SIDESTRING_1023");
	GVAR(current_mission_resolved_text) = (localize "STR_DOM_SIDESTRING_1024");
#endif
};

if (call FUNC(checkSHC)) then {
	__PossAndOther
	_vehicle = objNull;
	_vehicle = createVehicle [GVAR(sm_plane), _poss, [], 0, "NONE"];
	_vehicle setDir (markerDir QGVAR(sm_102));
	_vehicle setPos _poss;
	sleep 2.123;
	["specops", 2, "basic", 4, _poss,100,true] spawn FUNC(CreateInf);
	sleep 2.221;
	["shilka", 1, "bmp", 1, "tank", 1, _pos_other,1,200,true] spawn FUNC(CreateArmor);
	[_vehicle] spawn FUNC(sidesteal);
	_vehicle addMPEventHandler ["MPKilled", {
		if (isServer) then {
			private "_vec";
			PARAMS_2(_vec,_killer);
			__addDead(_vec);
			if (GVAR(domdatabase)) then {
				if (isPlayer _killer) then {_killer call FUNC(PAddPlaneKillPoints)};
			};
		};
	}];
	_vehicle setDamage 0;
};
